package com.binest.winnersList.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.binest.common.annotation.Log;
import com.binest.common.core.controller.BaseController;
import com.binest.common.core.domain.AjaxResult;
import com.binest.common.enums.BusinessType;
import com.binest.winnersList.domain.WinnersList;
import com.binest.winnersList.service.IWinnersListService;
import com.binest.common.utils.poi.ExcelUtil;
import com.binest.common.core.page.TableDataInfo;

/**
 * 获奖名单Controller
 * 
 * @author wwd
 * @date 2024-01-19
 */
@RestController
@RequestMapping("/winnersList")
public class WinnersListController extends BaseController
{
    @Autowired
    private IWinnersListService winnersListService;

    /**
     * 查询获奖名单列表
     */
    @PreAuthorize("@ss.hasPermi('winnersList:winnersList:list')")
    @GetMapping("/list")
    public TableDataInfo list(WinnersList winnersList)
    {
        startPage();
        List<WinnersList> list = winnersListService.selectWinnersListList(winnersList);
        return getDataTable(list);
    }

    /**
     * 导出获奖名单列表
     */
    @PreAuthorize("@ss.hasPermi('winnersList:winnersList:export')")
    @Log(title = "获奖名单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WinnersList winnersList)
    {
        List<WinnersList> list = winnersListService.selectWinnersListList(winnersList);
        ExcelUtil<WinnersList> util = new ExcelUtil<WinnersList>(WinnersList.class);
        util.exportExcel(response, list, "获奖名单数据");
    }

    /**
     * 获取获奖名单详细信息
     */
    @PreAuthorize("@ss.hasPermi('winnersList:winnersList:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(winnersListService.selectWinnersListById(id));
    }

    /**
     * 新增获奖名单
     */
    @PreAuthorize("@ss.hasPermi('winnersList:winnersList:add')")
    @Log(title = "获奖名单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WinnersList winnersList)
    {
        return toAjax(winnersListService.insertWinnersList(winnersList));
    }

    /**
     * 修改获奖名单
     */
    @PreAuthorize("@ss.hasPermi('winnersList:winnersList:edit')")
    @Log(title = "获奖名单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WinnersList winnersList)
    {
        return toAjax(winnersListService.updateWinnersList(winnersList));
    }

    /**
     * 删除获奖名单
     */
    @PreAuthorize("@ss.hasPermi('winnersList:winnersList:remove')")
    @Log(title = "获奖名单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(winnersListService.deleteWinnersListByIds(ids));
    }
}
